package com.yourenbang.lingyun.transaction.config;


import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.yourenbang.lingyun.constants.enums.mq.MqEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;


@Configuration
@ConfigurationProperties(prefix = "rocketmq")
public class MqConfig {

    @Value("${rocketmq.accessKey}")
    private String apiKeyMq;

    @Value("${rocketmq.secretKey}")
    private String secretKeyMq;

    @Value("${rocketmq.nameSrvAddr}")
    private String nameSrvAddrMq;


    public Properties getMqPropertie() {
        Properties properties = new Properties();
        properties.setProperty(PropertyKeyConst.AccessKey, this.apiKeyMq);
        properties.setProperty(PropertyKeyConst.SecretKey, this.secretKeyMq);
        properties.setProperty(PropertyKeyConst.NAMESRV_ADDR, this.nameSrvAddrMq);
        properties.setProperty(PropertyKeyConst.GROUP_ID, MqEnum.GroupIdEnum.GID_SERVICE_TRANSACTION.name());
        properties.setProperty(PropertyKeyConst.SendMsgTimeoutMillis, "3000");
        return properties;
    }


}
